<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>操作日志</title>
    <script src="/jquery/jquery-3.2.1.min.js"></script>
    <script src="/layui/layui.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/ztree/css/metroStyle/metroStyle.css"/>
    <script type="text/javascript" src="/ztree/js/jquery.ztree.all.min.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width: 100%;
            height: 800px;
        }
        .list{
            width: 1650px;
            height: 50px;
            margin: 0 20px;
            background-color:rgb(243,243,243);
        }
        .list-left{
            width: 100px;
            height: 30px;
            margin-top: 10px;
            float: left;
        }
        .list-left-left{
            width: 10px;
            height: 30px;
            float: left;
            background: green;
        }
        .list-left-right{
            width: 80px;
            height: 30px;
            font-size: 14px;
            line-height: 30px;
            float: left;
            text-indent: 5px;
        }
        .list-right{
            float: right;
            margin-top: 5px;
            margin-right: 45px;
        }
        .query{
            width: 1650px;
            height: 100px;
            margin: 20px 20px;
        }
        .layui-col-md11{
            width: 100%;
        }
        .layui-card-header{
            background-color:rgb(243,243,243);
        }
        .query-top-right{
            float: right;
            margin-right: 30px;
        }
        .layui-form-label{
            width: 130px;
        }
        .layui-form-item .layui-input-inline {
            float: left;
            width: 150px;
            margin-right: 10px;
        }
        .record{
            width: 1650px;
            height: 821px;
            margin-top: 40px;
            margin-left: 20px;
            background-color:rgb(243,243,243);
        }
        .record-right{
            width: 1350px;
            height: 700px;
            margin-left: 25px;
            float: left;
        }
        #button_ids{
            display: none;
        }
        .layui-table-cell {
            line-height: 47px;
            height: inherit;
        }
        .layui-table-cell>a{
            color:green;
        }
        .box-btngroup{
            width: 1300px;
            height: 30px;
            margin: 10px auto;
        }
        .layui-card-body{
            width: 1590px;
            height: 50px;
            margin-top: 20px;
        }
    </style>
</head>
<body>
<div class="box">
    <!--商品列表-->
    <div class="list">
        <div class="list-left">
            <div class="list-left-left"></div>
            <p class="list-left-right">操作日志</p>
        </div>
        <div class="list-right">
            <div class="list-right-left layui-btn layui-icon layui-icon-refresh" onclick="refresh()">&nbsp;刷新</div>
            <div class="list-right-right layui-btn layui-icon layui-icon-left" id="goBack">&nbsp;返回</div>
        </div>
    </div>
    <!--筛选查询-->
    <div class="layui-row query">
        <div class="layui-col-md11">
            <div class="layui-card headerCenter">
                <div class="layui-card-header backColor">
                    <i class="layui-icon">&#xe615;</i>
                    筛选查询
                </div>
                <div class="layui-card-body">
                    <form class="layui-form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">管理员名称：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="trueName" placeholder="请输入管理员名称" autocomplete="off" class="layui-input">
                            </div>

                            <label class="layui-form-label">操作的列表：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="remark" class="layui-input" placeholder="请输入操作的列表"/>
                            </div>

                            <label class="layui-form-label">操作类型：</label>
                            <div class="layui-input-inline">
                                <select class="layui-select" name="type"  id="type" value="请选择操作类型">
                                    <option value=""></option>
                                    <option value="0">日志</option>
                                    <option value="1">编辑</option>
                                    <option value="2">删除</option>
                                    <option value="3">查看</option>
                                </select>
                            </div>

                            <label class="layui-form-label">操作时间：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="createDate" id="createDate" class="layui-input" placeholder="请选择操作时间"/>
                            </div>

                            <div style="float: right;">
                                <button type="button" class="layui-btn" onclick="search()">
                                    <i class="layui-icon layui-icon-search"></i> 搜索
                                </button>
                                <button type="reset" class="layui-btn layui-btn-warm">
                                    <i class="layui-icon layui-icon-refresh"></i> 重置
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!--数据列表-->
    <div class="record">
        <div class="record-right">
            <!--表-->
            <table id="demoTable" lay-filter="demoTable"></table>
        </div>
    </div>
    <!--表头样式-->
    <div id="button_ids">
        <i class="layui-icon layui-icon-align-left"></i> 商品操作日志列表
    </div>
    <!--表内操作-->
    <div id="button_caozuo" style="display:none" >
        <a alt="删除" title="删除" lay-event="deleteTable">删除</a>
    </div>
    <a style="display: none" href="javascript:deleteTable(data.dictCode);">删除</a>
</div>
<!-- 返回 -->
<p id="title" style="display: none;">课程操作日志</p>
<script>
    /*parent.document.getElementById("iframe").height=0;
    parent.document.getElementById("iframe").height=document.body.scrollHeight;*/
</script>
<script>
    layui.use(['jquery','layer','table','laydate'],function(){
        var $=layui.jquery;
        var layer=layui.layer;
        var table=layui.table;
        var laydate = layui.laydate;
        //绑定时间格式
        laydate.render({
            //绑定元素
            elem: '#createDate',
            //日期和时间类型
            type: 'datetime',
            //时间事件为点击事件
            trigger: 'click'
        })

        getTable();
        function getTable() {
            $.ajax({
                url: '/course/getCourseOperationLog',
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    demoTable(data.data);
                }
            })
        }
        search = function search() {
            var trueName = $("input[name=trueName]").val();
            var remark = $("input[name=remark]").val();
            var type = $("#type option:selected").text();
            var newType;
            if(type == "查看"){
                newType=5
            }else if(type=="日志"){
                newType=1
            }else if(type=="编辑"){
                newType=4
            }else if(type=="删除"){
                newType=3
            }
            var createDate = $("input[name=createDate]").val();
            getTableByCondition(trueName,remark,newType,createDate);
        }
        function getTableByCondition(trueName,remark,newType,createDate){
            $.ajax({
                url: '/course/getCourseOperationLogSearch',
                type: 'post',
                dataType: 'json',
                data: {"trueName":trueName,"remark":remark,"type":newType,"createDate":createDate},
                success: function (data) {
                    demoTable(data.data);
                }
            })
        }
        /*表格*/
        function demoTable(data){
            table.render({
                elem:'#demoTable',
                title:"数据列表",
                data:data,
                toolbar:'#button_ids',
                limit:10,
                width:1600,
                page:{
                    layout:['count','prev','page','next','limit','skip','refresh'],
                    limits:[10],
                    first:"首页",
                    last:"尾页",
                },
                cols:[[
                    {type:"checkbox",float:"left"},
                    {title:"序号",align:'center',width:100,templet:function (data) {
                            return data.LAY_INDEX;
                        }},
                    {field:"trueName",title:"管理员名称",align:'center',width:250},
                    {field:"remark",title:"操作的列表",align:'center',width:250},
                    {field:"createDate",title:"执行时间",align:'center',width:250},
                    {field:"type",title:"操作类型",align:'center',width:250,templet:function (data) {
                        if(data.type==1){
                            return "日志"
                        }else if(data.type == 3){
                            return "删除"
                        }else if(data.type==4){
                            return "编辑"
                        }else if(data.type==5){
                            return "查看"
                        }
                    }},
                    {field:"",title:"备注",align:'center',width:248,templet:function (data) {
                                return '无内容';
                        }},
                    {title:"操作",align:'center',width:195,templet:function (data) {
                            return "<a onclick='javascript:deleteTable("+data.logId+")'>删除</a>"
                        }}
                ]]
            })
        }
        deleteTable = function deleteTable(logId){
            layer.confirm('确认要删除吗?', {icon: 3, title:'提示'}, function(index){
                $.ajax({
                    url: '/JsLog/deleteProductJsLog',
                    type: 'post',
                    dataType: 'json',
                    data: {'logId':logId},
                    success: function (data) {
                        if(data.data){
                            getTable();
                        }
                    }
                })
                layer.close(index);
            })
        }
        //刷新
        refresh=function refresh(){
            location.reload();
        }
        //返回
        $('#goBack').click(function () {
            var title = $('#title').text();
            var iframe = parent.$('.iframe');
            $.each(iframe,function (i,item) {
                if(title == $(item).attr('_href')){
                    parent.$('#beforeHref').val($(item).attr('_href'));
                    parent.beforeHref();
                    return;
                }
            });
        });

    })

</script>
</body>
</html>